// pages/zixunshi_lfy/zixunshi_lfy.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
        photo:'',
        city:'',
        title:'',
        name:'',
        time:'',
        guanxi:[],
        shoufei:[
            {
                // title:"语音咨询",
                value:"18人已咨询",
                // num:"500",
                label:"/次（1小时）"
            },
           
        ],
        huifu:[
            
        ],
        pingjia:[
           
        ],
        course:["心理科普：巴纳姆效应","心理科普：巴纳姆效应","心理科普：巴纳姆效应"],
        value:3,
        value1:3,
        value2:3,
  },
  onChange(event) {
    this.setData({
      value: event.detail,
    });
  },
  onChange1(event) {
    this.setData({
      value1: event.detail,
    });
  },
  onChange2(event) {
    this.setData({
      value2: event.detail,
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const send=options.clickedPerson;
    wx.request({
      url: 'http://localhost:8080/zixunshi/city?id='+send,
      method:'GET',
      success:(res)=>{
          const data=res.data.data;
          console.log(data);
          var adept=data[1].adeptLfyList;
          var guanxi = [];
          for (var i = 0; i < adept.length; i++) {
            guanxi.push(adept[i].adeptName);
          }
          var fee=data[2].feeLfyList;
          var shoufei=[];
          for (var i = 0; i < fee.length; i++) {
              shoufei.push(fee[i]);
          }
          this.setData({
            city:data[0].zixunshiAddress.split('·')[1],
            title:data[0].grade_lfy.gradeName,
            photo:data[0].zixunshiPhoto,
            name:data[0].zixunshiName,
            guanxi:guanxi,
            shoufei:shoufei
          })
      }
    }),
    wx.request({
        url: 'http://localhost:8080/problem/all',
        method:'GET',
        success:(res)=>{
            // console.log(res.data.data);
            var problem =res.data.data;
            var huifu=[];
            for(var i=0;i<problem.length;i++){
                // console.log(problem[i]);
                huifu.push(problem[i]);
            }
            this.setData({
                huifu:huifu,
            })
        }
    }),
    wx.request({
        url: 'http://localhost:8080/evaluation/select',
        method:'GET',
        success:(res)=>{
            // console.log(res.data.data);
            var evaluation =res.data.data;
            var pingjia=[];
            for(var i=0;i<evaluation.length;i++){
                // console.log(evaluation[i]);
                pingjia.push(evaluation[i]);
            }
            this.setData({
                pingjia:pingjia,
            })
        }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    let currentDate = new Date();
    let year = currentDate.getFullYear();
    let month = String(currentDate.getMonth() + 1).padStart(2, '0');
    let day = String(currentDate.getDate()).padStart(2, '0');
    let hours = String(currentDate.getHours()).padStart(2, '0');
    let minutes = String(currentDate.getMinutes()).padStart(2, '0');
    let seconds = String(currentDate.getSeconds()).padStart(2, '0');
    let formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
    console.log(formattedDate);
    this.setData({
        time:formattedDate
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})